import request from '@/utils/request'

/**
 * 角色列表分页查询
 * @param {*} page
 * @param {*} pageSize
 * @param {*} roleSearchDto
 * @returns
 */
export function pageList(page, pageSize, roleSearchDto) {
  return request({
    url: '/role/pageList',
    method: 'post',
    params: {
      page,
      pageSize
    },
    data: roleSearchDto
  })
}
/**
 * 修改角色状态
 * @param {*} roleId
 * @param {*} status
 * @returns
 */
export function updateRoleStatus(roleId, status) {
  return request({
    url: '/role/updateRoleStatus',
    method: 'put',
    params: {
      roleId,
      status
    }
  })
}
/**
 * 删除角色
 * @param {*} roleId
 * @returns
 */
export function deleteByRoleId(roleId) {
  return request({
    url: `/role/deleteByRoleId/${roleId}`,
    method: 'delete'
  })
}

/**
 * 根据角色id获取角色信息回显
 * @param {*} roleId
 * @returns
 */
export function findByRoleId(roleId) {
  return request({
    url: `/role/findByRoleId/${roleId}`,
    method: 'get'
  })
}

/**
 * 新增角色
 * @param {*} roleData
 * @returns
 */
export function insertRole(roleData) {
  return request({
    url: '/role/insertRole',
    method: 'post',
    data: roleData
  })
}

/**
 * 修改角色
 * @param {*} roleData
 * @returns
 */
export function updateRole(roleData) {
  return request({
    url: '/role/updateRole',
    method: 'put',
    data: roleData
  })
}
/**
 * 获取当前角色id获取所拥有的菜单列表
 * @param {*} roleId
 * @returns
 */
export function toAssign(roleId) {
  return request({
    url: `/role/toAssign/${roleId}`,
    method: 'get',
    params: {
      roleId
    }
  })
}
/**
 *为角色分配菜单
 * @param {*} assignRoleMenuDto
 * @returns
 */
export function doAssign(assignRoleMenuDto) {
  return request({
    url: '/role/doAssign',
    method: 'post',
    data: assignRoleMenuDto
  })
}
